package com.example.iotmanagerment26.mapper;

import com.example.iotmanagerment26.domain.ActObj;
import com.example.iotmanagerment26.domain.Data;
import com.example.iotmanagerment26.domain.Oprecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OprecordMapper {
    @Select("select * from oprecord where username=#{username}")
    List<Oprecord> selectOprecordsByName(String username);

    @Insert("insert into oprecord value(null,#{devid},#{types},#{subdevid},#{unit},#{act},#{content},#{sendtime},#{username})")
    int insert(ActObj a1);

    @Select("select * from data where name=#{name} ORDER BY time DESC LIMIT 1")
    Data getData(String device);

    @Select("select * from data where name=#{name} ORDER BY time DESC LIMIT 100")
    List<Data> getDataList(String device);

    @Select("select * from oprecord where name=#{name} ORDER BY id DESC LIMIT 20")
    List<Oprecord> getOprecord(String device);
}
